/**
 * 
 */
package com.zzu.icukangfu.serviceimpl;

import java.util.List;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.zzu.icukangfu.entity.Patient;
import com.zzu.icukangfu.entity.Physician;
import com.zzu.icukangfu.service.PhysicianService;

/**
 * @author teng
 * @time下午5:47:12
 * @corporation ttkj
 */
public class PhysicianServiceImpl implements PhysicianService {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.zzu.icukangfu.service.PhysicianService#addPhysician(com.zzu.icukangfu.
	 * entity.Physician)
	 */
	// @Override
	// @Before(Tx.class)
	// public String addPhysician(Physician physician) {
	// String sql="insert into
	// physician(physician_username,physician_password,physician_authority,physician_logintime)
	// values(?,?,?,?)";
	// return null;
	// }
	public String addPhysician(Physician physician) {
		String sql = "insert into physician(name)";
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.zzu.icukangfu.service.PhysicianService#login(java.lang.String)
	 */
	@Override
	public Boolean login(String username, String password) {

		String sql = "select * from physician_password where physician_username=?";
		Physician physician = Physician.dao.findFirst(sql, username);
		String pass = physician.getStr("physician_password");
		return pass.equals(password);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.zzu.icukangfu.service.PhysicianService#findThePhysician(java.lang.String)
	 */
	@Override
	public Physician findThePhysician(String username) {
		String sql = "select * from physician where username=?";
		return Physician.dao.findFirst(sql, username);
	}

	public List<Patient> findAllPatient(String physician_id) {
		// "select a.*,b.* from patient_tm as a left join patient as b on
		// a.patient_id=b.patient_id where a.patient_id=? and date_sub(curdate(),
		// INTERVAL 60 DAY) <= date_format(a.patient_trainingtime,'%Y-%m-%d') order by
		// a.patient_trainingtime desc";
		String sql = "select * from patient where physician_id = ?";
		// TODO Auto-generated method stub
		return Patient.dao.find(sql, physician_id);
	}

}
